<?php

namespace app\common\controller;

use think\facade\Lang;
use think\facade\Env;
use think\facade\Config;
use think\facade\Session;
use think\facade\View;
use app\BaseController;

/**
 * 后台控制器基类
 */
class Backend extends BaseController
{
    public function init()
    {
        $request = $this->request;
        // 设置过滤方法 [移除HTML标签]
        //$request->filter(['strip_tags', 'htmlspecialchars']);

        $moduleName = app('http')->getName();
        $controllerName = strtolower($request->controller());
        $actionName = strtolower($request->action());

        // 语言检测
        //$lang = strip_tags($request->langset());

        $upload = \app\common\service\Config::getUploadSetting();

        // 配置信息
        $config = [
            'upload' => $upload,
            'moduleName' => $moduleName,
            'controllerName' => $controllerName,
            'actionName' => $actionName,
            'jsName' => str_replace('.', '/', $controllerName),
            //'moduleUrl' => rtrim(url("/{$moduleName}", '', false), '/'),
            'moduleUrl' => rtrim(url('/', [], false), '/') . '/',
            //'language' => $lang,
            'referer' => Session::get('referer')
        ];
        //$config = array_merge($config, Config::get('view.tpl_replace_string'));
        //Config::set(array_merge(Config::get('upload'), $upload), 'upload');

        // 渲染配置信息
        View::assign('system_config', json_encode($config));
    }

    /*// 方法不存在
    public function __call($method, $args)
    {
        return $method . '方法不存在!';
    }*/
}